{include file="common/head"}

<head>
    <title>垃圾筒管理</title>

    <style>
        .form-control {
            width: initial;
            display: inline-block;
        }
    </style>
</head>

<body>
    <div class="container-fluid">

        <form action="/index.php/goods/index" method="post">
            <div class="row" id="query_bar" style="height: 50px;line-height: 50px;">
                <div class="col-4" style="text-align: left;line-height: 50px;font-size: 2rem;">回收站管理</div>
                <div class="col">
                    <label for="name">关键字：
                        <input class="form-control" type="text" value="" id="name" name="name"
                            placeholder="名称关键字" />
                    </label>

                    <button type="button" class="btn btn-warning query" style="vertical-align: middle;">
                        <span class="bi-search"></span>
                    </button>


                </div>

            </div>
        </form>

        
        <table class="table table-sm table-hover table-striped table-bordered" >
            <thead class="table-info">
                <th>序号</th>
                <th>名称</th>
                <th>数据表</th>
                <th class="long_field">数据</th>
                <th>录入人</th>
                <th>录入时间</th>
                <th>

                </th>
            </thead>
            <tbody>
                {foreach $list['data'] as $k=>$v}
                <tr>
                    <td>{$k+1}</td>
                    <td>{$v['name']}</td>
                    <td>{$v['table_name']}</td>
                    <td class="long_field">{$v['data']}</td>
                    <td>{$v['creater']}</td>
                    <td>{$v['create_time']}</td>
                    <td>
                        <a href="/trash/restore/id/{$v['id']}/table/{$v['table_name']}/erase/1">
                        <button class="btn btn-sm btn-danger "  ><span class="bi-x">清理</span></button>
                    </a>

                        <a href="/trash/restore/id/{$v['id']}/table/{$v['table_name']}">
                            <button class="btn btn-sm btn-info"><span class="bi-file-plus">恢复</span></button>
                        </a>
                    </td>

                </tr>
                {/foreach}

            </tbody>
        </table>
        {include file="common/pagination"}
    </div>

</body>

<script type="text/javascript">
    $(document).ready(function () {

        $(".query").on('click', function () {
            var index = layer.load(0, { shade: false }); //0代表加载的风格，支持0-2
            var cid = $("#customer_id").val();
            var order_no = $("#order_no").val();
            var sdate = $("#sdate").val();
            var edate = $("#edate").val();

            $("form").submit();
            layer.close(index);
        })

        $(".goods_image").on('click', function () {
            var img = $(this).attr('src');
            if (!img.trim()) return;

            layer.open({
                type: 1,
                offset: ['10px', '10px'],
                title: '',
                closeBtn: 0, //不显示关闭按钮
                anim: 1,
                time: 5 * 1000,
                shadeClose: true, //开启遮罩关闭              
                skin: 'layui-layer-rim',
                content: "<img src='" + img + "' style='width:100%'>"
            });
        })

        $('.goods_del,.spec_del').on('click', function () {
            var sp_id = $(this).attr('spec_id');
            var goods_id = $(this).attr('goods_id');
            var name = $(this).attr('name');

            if (sp_id) {
                var method = 'spec_del';
                var data = { id: sp_id };
                //询问框
            } else if (goods_id) {
                var method = 'goods_del';
                data = { id: goods_id };
            }

            layer.confirm('是否确定删除项目[' + name + ']?', {
                btn: ['确定删除', '再检查一下'] //按钮
            }, function () {

                $.ajax({
                    url: '/index.php/goods/' + method,
                    type: 'post',
                    data: data,
                    success: function (res) {
                        if (res.code) {
                            layer.msg('删除成功!');
                            location.reload();
                        } else {
                            layer.msg(res.msg);
                        }

                    },
                    fail: function (res) {
                        layer.msg(res.code + 'failed!');
                    }
                });

                e.preventDefault();

            }, function () {
                layer.msg('操作取消！');
                return false;
                e.preventDefault(); //阻止冒泡
            });


        })
    })
</script>


</body>

</html>